#include <iostream>
#include <queue>
using namespace std;

struct floor
{
    int step;
    int ceng;
    int times;
} floors[201];

int main()
{
    ios::sync_with_stdio(false);
    queue<struct floor> Q;
    struct floor tmp;
    int visited[201];
    int N, A, B;
    int higherFloor, lowerFloor;
    bool found;
    while (true)
    {
        cin >> N;
        if (N == 0)
        {
            break;
        }
        cin >> A >> B;
        for (int i = 1; i <= N; i++)
        {
            cin >> floors[i].step;
            floors[i].ceng = i;
            floors[i].times = 0;
            visited[i] = false;
        }
        // clear the queue
        while (!Q.empty())
        {
            Q.pop();
        }
        // BFS
        Q.push(floors[A]);
        found = false;
        while (!Q.empty())
        {
            tmp = Q.front();
            Q.pop();
            if (tmp.ceng == B)
            {
                found = true;
                break;
            }
            higherFloor = tmp.ceng + tmp.step;
            if (higherFloor <= N && !visited[higherFloor])
            {
                floors[higherFloor].times += (tmp.times + 1); // record how many times you have pressed the button
                visited[higherFloor] = true;                  // Mark that you have visited the floor once, and there's no means to do that later.
                Q.push(floors[higherFloor]);                  // push to queue to bfs
            }
            lowerFloor = tmp.ceng - tmp.step;
            if (lowerFloor >= 1 && !visited[lowerFloor])
            {
                floors[lowerFloor].times += (tmp.times + 1);
                visited[lowerFloor] = true;
                Q.push(floors[lowerFloor]);
            }
        }
        if (found)
        {
            cout << tmp.times << endl;
        }
        else
        {
            cout << -1 << endl;
        }
    }
    return 0;
}